<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display" %>

<html>

  <head>
    <title><s:text name="invoicesaction.title"/></title>
		<link href="<s:url value='/css/print.css'/>" rel="stylesheet" type="text/css" />
  </head>

  <body>

    <table class="invicibleTable">
      <tr>
        <td width="80%">
            <hr class="hrInvoiceHr" />
        </td>
        <td class="hrInvoiceTextBold">
            FAKTURA <s:property value="model.hrInvoiceNumber"/>
        </td>
        <td width="20%">
            <hr class="hrInvoiceHr" />
        </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td class="hrInvoiceTextBold">
            <SMALL>ORYGINAŁ / KOPIA</SMALL>
        </td>
        <td>&nbsp;</td>
      </tr>
    </table>

    <br />

    <table class="invicibleTable">
      <tr>
        <td width="100%" style="border-bottom: 1px solid #000;">
            <strong>Nabywca:</strong>
        </td>
        <td>
            &nbsp;
        </td>
      </tr>
      <tr>
        <td style="vertical-align: top;">
          <table>
	        <tr>
	          <td class="nowrap" style="vertical-align: top;">
	            <strong>Nazwa:</strong>
	          </td>
	          <td width="100%" class="dottedLine" >
	            <s:property value="%{purchaserNameHTML}" escape="false" default="-"/>
	            &nbsp;
	          </td>
	        </tr>
            <tr>
              <td class="nowrap" style="vertical-align: top;">
                <strong>Adres:</strong>
              </td>
              <td class="dottedLine">
                <s:property value="%{purchaserAddressHTML}" escape="false" default="-"/>
                &nbsp;
              </td>
            </tr>	        
            <tr>
              <td class="nowrap" style="vertical-align: top;">
                <strong>NIP:</strong>
              </td>
              <td class="dottedLine">
                <s:property value="%{purchaserNip}" escape="false" default="-"/>
                &nbsp;
              </td>
            </tr>
          </table>
        </td>
        <td style="vertical-align: top;">
          <table>
            <tr>
              <td class="nowrap" style="vertical-align: top;">
                <strong><s:text name="invoice.documentDate" /></strong>
              </td>
              <td class="nowrap dottedLine">
			      <s:text name="format.date">
			        <s:param value="model.documentDate"/>
			      </s:text>
              </td>
            </tr>
            <tr>
              <td class="nowrap" style="vertical-align: top;">
                <strong><s:text name="invoice.soldDate" /></strong>
              </td>
              <td class="nowrap dottedLine">
                  <s:text name="format.date">
                    <s:param value="model.soldDate"/>
                  </s:text>
              </td>
            </tr>
            <tr>
              <td class="nowrap" style="vertical-align: top;">
                <strong><s:text name="invoice.paymentDate" /></strong>
              </td>
              <td class="nowrap dottedLine">
                  <s:text name="format.date">
                    <s:param value="model.paymentDate"/>
                  </s:text>
              </td>
            </tr>
            <tr>
              <td class="nowrap" style="vertical-align: top;">
                <strong><s:text name="invoice.paymentKind" /></strong>
              </td>
              <td class="nowrap dottedLine">
                  <s:text name="%{paymentKind.descriptionKey}"/>
              </td>
            </tr>
          </table>
        </td>
      </tr>      
    </table>

    <p>&nbsp;</p>
    
    <table class="wwDetailsTable" cellspacing="0">
    
      <tr>
        <th rowspan="2" class="tbt tbr tbb tbl">
            <s:text name="invoicePosition.quantity"/>
        </th>
        <th rowspan="2" class="tbt tbr tbb">
            <s:text name="invoicePosition.serviceName"/>
        </th>
        <th rowspan="2" class="tbt tbr tbb">
            <s:text name="invoicePosition.symbol"/>
        </th>
        <th rowspan="2" class="tbt tbr tbb">
            <s:text name="invoicePosition.measure"/>
        </th>
        <th rowspan="2" class="tbt tbr tbb">
            <s:text name="invoicePosition.priceNetto"/>
        </th>
        <th rowspan="2" class="colValueNetto tbt tbr tbb">
            <s:text name="invoicePosition.valueNetto"/>
        </th>
        <th colspan="2" class="tbt tbb">
            <s:text name="invoicePosition.tax"/>
        </th>
        <th rowspan="2" class="tbt tbr tbb tbl">
            <s:text name="invoicePosition.total"/>
        </th>
      </tr>

      <tr>
        <th class="colInterestRate tbr tbb">
            <s:text name="invoicePosition.interestRate"/>
        </th>
        <th class="colSum tbb">
            <s:text name="invoicePosition.sum"/>
        </th>
      </tr>
      
      <s:iterator value="model.invoicePositions">
      
      <tr>
        <td class="integer tbl tbr">
          <s:property value="quantity"/>
        </td>
        <td class="tbr">
          <s:property value="serviceName"/>
        </td>
        <td class="tbr">
          <s:property value="symbol"/>
        </td>
        <td class="tbr">
          <s:property value="measure"/>
        </td>
        <td class="money tbr">
          <s:text name="format.money">
            <s:param value="priceNetto"/>
          </s:text>
        </td>
        <td class="money tbr">
          <s:text name="format.money">
            <s:param value="valueNetto"/>
          </s:text>
        </td>
        <td class="integer tbr">
          <s:text name="format.integer">
            <s:param value="interestRate"/>
          </s:text>%
        </td>
        <td class="money">
          <s:text name="format.money">
            <s:param value="sum"/>
          </s:text>
        </td>
        <td class="money tbl tbr">
          <s:text name="format.money">
            <s:param value="total"/>
          </s:text>
        </td>
      </tr>
      
      </s:iterator>
      
      <%-- table close --%>
      <tr>
        <td class="tbb tbl tbr">
          &nbsp;<br />
          &nbsp;<br />
          &nbsp;<br />
          &nbsp;<br />
          &nbsp;<br />
          &nbsp;<br />
        </td>
        <td class="tbb tbr">&nbsp;</td>
        <td class="tbb tbr">&nbsp;</td>
        <td class="tbb tbr">&nbsp;</td>
        <td class="tbb tbr">&nbsp;</td>
        <td class="tbb tbr">&nbsp;</td>
        <td class="tbb tbr">&nbsp;</td>
        <td class="tbb">&nbsp;</td>
        <td class="tbb tbl tbr">&nbsp;</td>
      </tr>
      
      <tr>
        <td colspan="9">
          &nbsp;<br />
        </td>
      </tr>
      
      <%-- podsumowanie --%>
      <tr>
        <td colspan="4" rowspan="2" class="nounderline">
            <b>Słownie złotych:</b><br/>
            <s:text name="invoicesaction.humanReadableTotal">
                <s:param value="model.hrTotalIntegerPart" />
                <s:param value="model.hrTotalDigitsPart" />
            </s:text> 
        </td>
        <td class="money">
          <b><s:text name="invoicePosition.allTogether"/>&nbsp;</b>
        </td>
        <td class="money tbt2 tbb2 tbl2 tbr2">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[1.0].valueNetto"/>
          </s:text>
        </td>
        <td>
          &nbsp;
        </td>
        <td class="money tbt2 tbb2 tbr2 tbl2">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[1.0].sum"/>
          </s:text>
        </td>
        <td class="money tbt2 tbb2 tbr2">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[1.0].total"/>
          </s:text>
        </td>
      </tr>

      <tr>
        <td>&nbsp;</td>
        <td class="tbb">&nbsp;</td>
        <td class="tbb">&nbsp;</td>
        <td class="tbb">&nbsp;</td>
        <td class="tbb">&nbsp;</td>
      </tr>

      <s:iterator id="key" value="model.calculatedSummariesKeys" status="status">
      <tr>
        <td colspan="4" class="nounderline">&nbsp;</td>
        <td class="money nounderline">
          <s:if test="#status.first">
            <b><s:text name="invoicePosition.allTogetherFactors"/>&nbsp;</b>
          </s:if>
        </td>
        <td class="money tbl tbb tbr">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[#key].valueNetto"/>
          </s:text>
        </td>
        <td class="integer tbr tbb">
          <s:text name="format.integer">
            <s:param value="model.calculatedSummaries[#key].interestRate"/>
          </s:text>%
        </td>
        <td class="money tbr tbb">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[#key].sum"/>
          </s:text>
        </td>
        <td class="money tbr tbb">
          <s:text name="format.money">
            <s:param value="model.calculatedSummaries[#key].total"/>
          </s:text>
        </td>
      </tr>
      </s:iterator>
      
    </table>

    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    
    <table class="invicibleTable">
      <tr>
        <td width="40%" class="dottedLine">
            &nbsp;
        </td>
        <td>
            &nbsp;
        </td>        
        <td width="40%" class="dottedLine">
            &nbsp;
        </td>        
      </tr>
      <tr>
        <td align="center">
            <i>Osoba upoważniona do odbioru faktury</i>
        </td>
        <td>
            &nbsp;
        </td>        
        <td align="center">
            <i>Osoba upoważniona do wystawienia faktury</i>
        </td>        
      </tr>
    </table>


  </body>

</html>
